// @ts-nocheck
import React, { useEffect } from "react";
import { NavBar, Space, Badge } from "antd-mobile";
import { useNavigate, useSearchParams } from "react-router-dom";

import IconBox from "@/components/IconBox";
// imgages
import eventreport from "../../images/icon/eventreport.png";
import eventlist from "../../images/icon/eventlist.png";
import emergencylist from "../../images/icon/emergencylist.png";
import emergencyReport from "../../images/icon/emergencyReport.png";
import potential from "../../images/icon/potential.png";
import dataCollect from "../../images/icon/dataCollect.png";
import personImg from "../../images/icon/personImg.png";

// style
import "./index.less";

const common: { name: string; img: string; url: string }[] = [
  {
    name: "事件上报",
    img: eventreport,
    url: "/eventReport",
  },
  {
    name: "事件列表",
    img: eventlist,
    url: "/home/job/list",
  },
  {
    name: "城运调度",
    img: emergencyReport,
    url: "/cityDispatch",
  },
  // {
  //   name: "指挥调度事件",
  //   img: emergencylist,
  //   url: "/commandControl",
  // },
  //   {
  //     name: "应急上报",
  //     img: emergencyReport,
  //     url: "/emergencyReporting",
  //   },
  //   {
  //     name: "应急事件",
  //     img: emergencylist,
  //     url: "/home/emergency",
  //   },
  //   {
  //     name: "隐患排查",
  //     img: potential,
  //     url: "/home/potential",
  //   },
  //   {
  //     name: "重点人员管理",
  //     img: personImg,
  //     url: "/personnelList",
  //   },
  //   {
  //     name: "数据采集",
  //     img: dataCollect,
  //     url: "/dataCollection",
  //   },
];

const Index: React.FC<any> = () => {
  const navigate = useNavigate();

  useEffect(() => {
    if (
      decodeURI(location.search) &&
      decodeURI(location.search) != "?code=fromRzt"
    ) {
      // location.href=`/home/job/list${decodeURI(location.search)}`
      navigate(`/home/job/list`);
      sessionStorage.setItem("isOhther", true);
    }
  }, []);

  return (
    <div className="home">
      <div className="home-bannerBox">
        {/* <NavBar
          back={null}
          style={{
            backgroundColor: "#fff",
            color: "white",
            fontSize: "15rem",
          }}
        >
          首页
        </NavBar> */}
        <div className="home-bannerBox-title">事件上报</div>
        <div className="home-bannerBox-bannerBackground">
          <div className="home-bannerBox-banner"></div>
        </div>
      </div>

      <div className="common">
        {common.map((item, index) => {
          return (
            <div
              key={index}
              className="eventP"
              onClick={() => navigate(item.url)}
            >
              <Space wrap style={{ fontSize: "2rem" }}>
                <IconBox
                  image={
                    <img
                      style={{
                        height: "100%",
                        width: "100%",
                      }}
                      src={item.img}
                    />
                  }
                />
              </Space>
              <div className="title">{item.name}</div>
            </div>
          );
        })}
      </div>
    </div>
  );
};

export default Index;
